home *** CD-ROM | disk | FTP | other *** search
- /*
- File: RulerObject.h
-
- Contains: xxx put contents here xxx
-
- Written by: Essam Zaky
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 1/4/94 EZ clean up
- <1> 1/4/94 EZ first checked in
-
- */
-
- #ifndef _RulerObject_
- #define _RulerObject_
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _Array_
- #include "Array.h"
- #endif
-
- #ifndef _AttrObject_
- #include "AttrObject.h"
- #endif
-
- #ifndef _Streams_
- #include "Streams.h"
- #endif
-
- //***************************************************************************************************
-
- const ClassId kBasicRulerClassId = 'brlr';
-
- const AttrId kJustAttr = 'just'; //defined in CBasicRuler and CAdvancedRuler
-
- const AttrId kTabAttr = 'tabb';
- //defined only in CAdvancedRuler, declared here for CTextensionCommand
-
-
- //kJustAttr constants
- const char kLeftJust = 1;
- const char kRightJust = 2;
- const char kCenterJust = 4;
- const char kFullJust = 8;
- const char kForceFullJust = 16;
-
- //tab kind const, CBasicRuler supports only "kRepulsivTab", others are handled by "CAdvancedRuler"
- const char kRepulsivTab = 0;
- const char kCenterTab = 1;
- const char kAttractivTab = 2;
- const char kAlignTab = 3; //align on a uchar
-
- const short kDefaultTabVal = 30; //pixels
-
- //constants for updateMessage when kTabAttr
- //defined only in CAdvancedRuler, declared here for CTextensionCommand
- const long kRemoveTab = 1;
- const long kInsertTab = 2;
-
- //***************************************************************************************************
-
- struct Ttab {
- void Set(short tabValue, char tabKind, uchar tabAlign = 0);
-
- short value;
- char kind; //kRepulsivTab..kAlignTab
- uchar alignChar;
- };
- typedef Ttab* TtabPtr;
-
-
-
- struct TPendingTab {
- Boolean valid; //true if the "theTab" is pending tab
- Ttab theTab;
- Fixed tabWidth;
- };
- //***************************************************************************************************
-
-
- class CRulerObject : public CAttrObject { //abstract class for ruler objects
- public:
- CRulerObject();
-
- //•override
- virtual ClassId GetClassId() const = 0;
-
- virtual CAttrObject* CreateNew() const = 0;
-
- virtual void GetAttrIDs(short* countAttr, AttrId* attrArray) const = 0;
-
- //•own
- #ifdef txtnScal
- virtual Fixed GetEffectiveLineWidth(Fixed width, Boolean paragStart
- , short numer=1, short denom =1) const = 0;
-
- virtual Fixed GetLineLeftEdge(char direction, Boolean paragStart
- , short numer=1, short denom =1) const = 0;
-
- virtual Fixed GetTabWidth(Fixed tabPixStart, TPendingTab* pendingTab
- , short numer =1, short denom=1) const = 0;
- #else
- virtual Fixed GetEffectiveLineWidth(Fixed width, Boolean paragStart) const = 0;
-
- virtual Fixed GetLineLeftEdge(char direction, Boolean paragStart) const = 0;
-
- virtual Fixed GetTabWidth(Fixed tabPixStart, TPendingTab* pendingTab) const = 0;
- #endif
-
-
- virtual void AdjustLineHite(TLineHiteInfo* lineHiteInfo) const = 0;
- virtual Fixed CalcPendingTabWidth(const TPendingTab* pendingTab, Fixed tabTrailWidth
- , Fixed remainingWidth) const = 0;
-
-
- protected:
- //•override
- virtual Boolean EqualAttribute(AttrId theAttr, const void* valToCheck) const = 0;
-
- virtual void AttributeToBuffer(AttrId theAttr, void* attrBuffer) const = 0;
-
- virtual void BufferToAttribute(AttrId theAttr, const void* attrBuffer) = 0;
- };
- //***************************************************************************************************
-
- class CBasicRuler : public CRulerObject {
- public:
- CBasicRuler();
-
- inline void IBasicRuler() {this->IAttrObject();}
-
- //•override
- virtual ClassId GetClassId() const;
-
- virtual void GetAttrIDs(short* countAttr, AttrId* attrArray) const;
-
- virtual CAttrObject* CreateNew() const;
-
- virtual void SetDefaults(long message = 0);
-
- #ifdef txtnScal
- virtual Fixed GetEffectiveLineWidth(Fixed width, Boolean paragStart, short numer=1, short denom =1) const;
- virtual Fixed GetLineLeftEdge(char direction, Boolean paragStart, short numer=1, short denom =1) const;
- virtual Fixed GetTabWidth(Fixed tabPixStart, TPendingTab* pendingTab, short numer =1
- , short denom=1) const;
- #else
- virtual Fixed GetEffectiveLineWidth(Fixed width, Boolean paragStart) const;
- virtual Fixed GetLineLeftEdge(char direction, Boolean paragStart) const;
- virtual Fixed GetTabWidth(Fixed tabPixStart, TPendingTab* pendingTab) const;
- #endif
-
- virtual void AdjustLineHite(TLineHiteInfo* lineHiteInfo) const;
- virtual Fixed CalcPendingTabWidth(const TPendingTab* pendingTab, Fixed tabTrailWidth
- , Fixed remainingWidth) const;
-
-
- //input/output methods
- virtual OSErr WriteToStream(CStream* outputStream);
- virtual OSErr ReadFromStream(CStream* inputStream);
-
- protected:
- char fJust;
-
- //•override
- virtual Boolean EqualAttribute(AttrId theAttr, const void* valToCheck) const;
-
- virtual void AttributeToBuffer(AttrId theAttr, void* attrBuffer) const;
- virtual void BufferToAttribute(AttrId theAttr, const void* attrBuffer);
- };
- //***************************************************************************************************
-
- #endif
-